package com.shangrila.biz.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.shangrila.common.lang.Money;
/**
 * 商品信息
 * 
 * @author kalman03
 */
public class ShangrilaItem {

	private long id;
	/** 宝贝id */
	private long itemId;
	/** 宝贝标题 */
	private String title;
	/** 卖家昵称 */
	private String sellerNick;
	/** 宝贝价格 */
	private String price;
	/** 宝贝折扣价格 */
	private String couponPrice;
	/** 淘客Url */
	private String taokeUrl;
	/** 主图地址 */
	private String mainPicUrl;
	/** 全部图片的地址 */
	private String pictures;
	/** 所属一级类目 ：按人分，还是按照价格区间分 */
	private Long categoryLevel1;
	/** 所属二级类目：如价格区间的50元区 */
	private Long categoryLevel2;
	/** 添加原因 ,这个貌似只有按照人分的时候才有 */
	private String reasons;
	/**商品展示时间*/
	private Date showDate;
	
	private Date gmtCreate;
	private Date gmtModified;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getItemId() {
		return itemId;
	}

	public void setItemId(long itemId) {
		this.itemId = itemId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSellerNick() {
		return sellerNick;
	}

	public void setSellerNick(String sellerNick) {
		this.sellerNick = sellerNick;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getCouponPrice() {
		return couponPrice;
	}

	public void setCouponPrice(String couponPrice) {
		this.couponPrice = couponPrice;
	}

	public String getTaokeUrl() {
		return taokeUrl;
	}

	public void setTaokeUrl(String taokeUrl) {
		this.taokeUrl = taokeUrl;
	}

	public String getMainPicUrl() {
		return mainPicUrl;
	}

	public void setMainPicUrl(String mainPicUrl) {
		this.mainPicUrl = mainPicUrl;
	}

	public String getPictures() {
		return pictures;
	}

	public void setPictures(String pictures) {
		this.pictures = pictures;
	}

	public Long getCategoryLevel1() {
		return categoryLevel1;
	}

	public void setCategoryLevel1(Long categoryLevel1) {
		this.categoryLevel1 = categoryLevel1;
	}

	public Long getCategoryLevel2() {
		return categoryLevel2;
	}

	public void setCategoryLevel2(Long categoryLevel2) {
		this.categoryLevel2 = categoryLevel2;
	}

	public String getReasons() {
		return reasons;
	}

	public void setReasons(String reasons) {
		this.reasons = reasons;
	}

	public Date getShowDate() {
		return showDate;
	}

	public void setShowDate(Date showDate) {
		this.showDate = showDate;
	}

	public Date getGmtCreate() {
		return gmtCreate;
	}

	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}

	public Date getGmtModified() {
		return gmtModified;
	}

	public void setGmtModified(Date gmtModified) {
		this.gmtModified = gmtModified;
	}
	/**执行插入DB前的检查*/
	public void checkBeforeInsert(){
		
	}
	
	public List<String> getReasonList(){
		List<String> list = new ArrayList<String>();
		if(StringUtils.isNotBlank(reasons)){
			String [] array = reasons.split("@");
			for(String str : array){
				if(StringUtils.isNotBlank(str))
				list.add(str);
			}
		}
		return list;
	}
	
	public List<String> getPicList(){
		List<String> list = new ArrayList<String>();
		if(StringUtils.isNotBlank(pictures)){
			String [] array = pictures.split("@");
			for(String str : array){
				if(StringUtils.isNotBlank(str))
				list.add(str);
			}
		}
		return list;
	}
	
	public Money getPowerPrice(){
		if(new Money(0).compareTo(new Money(couponPrice)) <0){
			return new Money(couponPrice);
		}
		return new Money(price);
	}
}
